/**
 * @file
 *
 * @author OmniBlade
 * @author CCHyper
 *
 * @brief Class containing information about terrain templates.
 *
 * @copyright Chronoshift is free software: you can redistribute it and/or
 *            modify it under the terms of the GNU General Public License
 *            as published by the Free Software Foundation, either version
 *            2 of the License, or (at your option) any later version.
 *            A full copy of the GNU General Public License can be found in
 *            LICENSE
 */
#include "templatetype.h"
#include "gamefile.h"
#include "coord.h"
#include "gamedebug.h"
#include "minmax.h"
#include "mixfile.h"

#ifndef CHRONOSHIFT_STANDALONE
TFixedIHeapClass<TemplateTypeClass> &TemplateTypes = Make_Global<TFixedIHeapClass<TemplateTypeClass> >(0x0065DF84);
#else
TFixedIHeapClass<TemplateTypeClass> TemplateTypes;
#endif

enum TemplateTheater
{
    TEM_THR_NONE = 0,
    TEM_THR_TEMPERAT = 1 << 0,
    TEM_THR_SNOW = 1 << 1,
    TEM_THR_INTERIOR = 1 << 2,
    TEM_THR_ALL = TEM_THR_TEMPERAT | TEM_THR_SNOW | TEM_THR_INTERIOR,
};

// TemplateEmpty is a default template instance, never used.
const TemplateTypeClass TemplateEmpty(TEMPLATE_CLEAR, TEM_THR_ALL, "CLEAR1", TXT_CLEAR);

const TemplateTypeClass TemplateClear(TEMPLATE_CLEAR, TEM_THR_ALL, "CLEAR1", TXT_CLEAR);

const TemplateTypeClass TemplateRoad01(TEMPLATE_ROAD01, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D01", TXT_ROAD);
const TemplateTypeClass TemplateRoad02(TEMPLATE_ROAD02, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D02", TXT_ROAD);
const TemplateTypeClass TemplateRoad03(TEMPLATE_ROAD03, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D03", TXT_ROAD);
const TemplateTypeClass TemplateRoad04(TEMPLATE_ROAD04, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D04", TXT_ROAD);
const TemplateTypeClass TemplateRoad05(TEMPLATE_ROAD05, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D05", TXT_ROAD);
const TemplateTypeClass TemplateRoad06(TEMPLATE_ROAD06, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D06", TXT_ROAD);
const TemplateTypeClass TemplateRoad07(TEMPLATE_ROAD07, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D07", TXT_ROAD);
const TemplateTypeClass TemplateRoad08(TEMPLATE_ROAD08, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D08", TXT_ROAD);
const TemplateTypeClass TemplateRoad09(TEMPLATE_ROAD09, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D09", TXT_ROAD);
const TemplateTypeClass TemplateRoad10(TEMPLATE_ROAD10, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D10", TXT_ROAD);
const TemplateTypeClass TemplateRoad11(TEMPLATE_ROAD11, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D11", TXT_ROAD);
const TemplateTypeClass TemplateRoad12(TEMPLATE_ROAD12, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D12", TXT_ROAD);
const TemplateTypeClass TemplateRoad13(TEMPLATE_ROAD13, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D13", TXT_ROAD);
const TemplateTypeClass TemplateRoad14(TEMPLATE_ROAD14, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D14", TXT_ROAD);
const TemplateTypeClass TemplateRoad15(TEMPLATE_ROAD15, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D15", TXT_ROAD);
const TemplateTypeClass TemplateRoad16(TEMPLATE_ROAD16, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D16", TXT_ROAD);
const TemplateTypeClass TemplateRoad17(TEMPLATE_ROAD17, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D17", TXT_ROAD);
const TemplateTypeClass TemplateRoad18(TEMPLATE_ROAD18, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D18", TXT_ROAD);
const TemplateTypeClass TemplateRoad19(TEMPLATE_ROAD19, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D19", TXT_ROAD);
const TemplateTypeClass TemplateRoad20(TEMPLATE_ROAD20, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D20", TXT_ROAD);
const TemplateTypeClass TemplateRoad21(TEMPLATE_ROAD21, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D21", TXT_ROAD);
const TemplateTypeClass TemplateRoad22(TEMPLATE_ROAD22, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D22", TXT_ROAD);
const TemplateTypeClass TemplateRoad23(TEMPLATE_ROAD23, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D23", TXT_ROAD);
const TemplateTypeClass TemplateRoad24(TEMPLATE_ROAD24, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D24", TXT_ROAD);
const TemplateTypeClass TemplateRoad25(TEMPLATE_ROAD25, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D25", TXT_ROAD);
const TemplateTypeClass TemplateRoad26(TEMPLATE_ROAD26, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D26", TXT_ROAD);
const TemplateTypeClass TemplateRoad27(TEMPLATE_ROAD27, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D27", TXT_ROAD);
const TemplateTypeClass TemplateRoad28(TEMPLATE_ROAD28, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D28", TXT_ROAD);
const TemplateTypeClass TemplateRoad29(TEMPLATE_ROAD29, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D29", TXT_ROAD);
const TemplateTypeClass TemplateRoad30(TEMPLATE_ROAD30, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D30", TXT_ROAD);
const TemplateTypeClass TemplateRoad31(TEMPLATE_ROAD31, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D31", TXT_ROAD);
const TemplateTypeClass TemplateRoad32(TEMPLATE_ROAD32, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D32", TXT_ROAD);
const TemplateTypeClass TemplateRoad33(TEMPLATE_ROAD33, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D33", TXT_ROAD);
const TemplateTypeClass TemplateRoad34(TEMPLATE_ROAD34, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D34", TXT_ROAD);
const TemplateTypeClass TemplateRoad35(TEMPLATE_ROAD35, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D35", TXT_ROAD);
const TemplateTypeClass TemplateRoad36(TEMPLATE_ROAD36, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D36", TXT_ROAD);
const TemplateTypeClass TemplateRoad37(TEMPLATE_ROAD37, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D37", TXT_ROAD);
const TemplateTypeClass TemplateRoad38(TEMPLATE_ROAD38, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D38", TXT_ROAD);
const TemplateTypeClass TemplateRoad39(TEMPLATE_ROAD39, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D39", TXT_ROAD);
const TemplateTypeClass TemplateRoad40(TEMPLATE_ROAD40, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D40", TXT_ROAD);
const TemplateTypeClass TemplateRoad41(TEMPLATE_ROAD41, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D41", TXT_ROAD);
const TemplateTypeClass TemplateRoad42(TEMPLATE_ROAD42, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D42", TXT_ROAD);
const TemplateTypeClass TemplateRoad43(TEMPLATE_ROAD43, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D43", TXT_ROAD);
const TemplateTypeClass TemplateRoad44(TEMPLATE_ROAD44, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D44", TXT_ROAD);
const TemplateTypeClass TemplateRoad45(TEMPLATE_ROAD45, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "D45", TXT_ROAD);

const TemplateTypeClass TemplateWater(TEMPLATE_WATER, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "W1", TXT_WATER);
const TemplateTypeClass TemplateWater2(TEMPLATE_WATER2, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "W2", TXT_WATER);

const TemplateTypeClass TemplateShore01(TEMPLATE_SHORE01, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH01", TXT_SHORE);
const TemplateTypeClass TemplateShore02(TEMPLATE_SHORE02, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH02", TXT_SHORE);
const TemplateTypeClass TemplateShore03(TEMPLATE_SHORE03, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH03", TXT_SHORE);
const TemplateTypeClass TemplateShore04(TEMPLATE_SHORE04, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH04", TXT_SHORE);
const TemplateTypeClass TemplateShore05(TEMPLATE_SHORE05, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH05", TXT_SHORE);
const TemplateTypeClass TemplateShore06(TEMPLATE_SHORE06, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH06", TXT_SHORE);
const TemplateTypeClass TemplateShore07(TEMPLATE_SHORE07, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH07", TXT_SHORE);
const TemplateTypeClass TemplateShore08(TEMPLATE_SHORE08, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH08", TXT_SHORE);
const TemplateTypeClass TemplateShore09(TEMPLATE_SHORE09, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH09", TXT_SHORE);
const TemplateTypeClass TemplateShore10(TEMPLATE_SHORE10, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH10", TXT_SHORE);
const TemplateTypeClass TemplateShore11(TEMPLATE_SHORE11, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH11", TXT_SHORE);
const TemplateTypeClass TemplateShore12(TEMPLATE_SHORE12, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH12", TXT_SHORE);
const TemplateTypeClass TemplateShore13(TEMPLATE_SHORE13, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH13", TXT_SHORE);
const TemplateTypeClass TemplateShore14(TEMPLATE_SHORE14, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH14", TXT_SHORE);
const TemplateTypeClass TemplateShore15(TEMPLATE_SHORE15, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH15", TXT_SHORE);
const TemplateTypeClass TemplateShore16(TEMPLATE_SHORE16, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH16", TXT_SHORE);
const TemplateTypeClass TemplateShore17(TEMPLATE_SHORE17, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH17", TXT_SHORE);
const TemplateTypeClass TemplateShore18(TEMPLATE_SHORE18, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH18", TXT_SHORE);
const TemplateTypeClass TemplateShore19(TEMPLATE_SHORE19, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH19", TXT_SHORE);
const TemplateTypeClass TemplateShore20(TEMPLATE_SHORE20, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH20", TXT_SHORE);
const TemplateTypeClass TemplateShore21(TEMPLATE_SHORE21, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH21", TXT_SHORE);
const TemplateTypeClass TemplateShore22(TEMPLATE_SHORE22, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH22", TXT_SHORE);
const TemplateTypeClass TemplateShore23(TEMPLATE_SHORE23, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH23", TXT_SHORE);
const TemplateTypeClass TemplateShore24(TEMPLATE_SHORE24, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH24", TXT_SHORE);
const TemplateTypeClass TemplateShore25(TEMPLATE_SHORE25, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH25", TXT_SHORE);
const TemplateTypeClass TemplateShore26(TEMPLATE_SHORE26, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH26", TXT_SHORE);
const TemplateTypeClass TemplateShore27(TEMPLATE_SHORE27, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH27", TXT_SHORE);
const TemplateTypeClass TemplateShore28(TEMPLATE_SHORE28, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH28", TXT_SHORE);
const TemplateTypeClass TemplateShore29(TEMPLATE_SHORE29, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH29", TXT_SHORE);
const TemplateTypeClass TemplateShore30(TEMPLATE_SHORE30, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH30", TXT_SHORE);
const TemplateTypeClass TemplateShore31(TEMPLATE_SHORE31, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH31", TXT_SHORE);
const TemplateTypeClass TemplateShore32(TEMPLATE_SHORE32, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH32", TXT_SHORE);
const TemplateTypeClass TemplateShore33(TEMPLATE_SHORE33, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH33", TXT_SHORE);
const TemplateTypeClass TemplateShore34(TEMPLATE_SHORE34, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH34", TXT_SHORE);
const TemplateTypeClass TemplateShore35(TEMPLATE_SHORE35, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH35", TXT_SHORE);
const TemplateTypeClass TemplateShore36(TEMPLATE_SHORE36, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH36", TXT_SHORE);
const TemplateTypeClass TemplateShore37(TEMPLATE_SHORE37, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH37", TXT_SHORE);
const TemplateTypeClass TemplateShore38(TEMPLATE_SHORE38, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH38", TXT_SHORE);
const TemplateTypeClass TemplateShore39(TEMPLATE_SHORE39, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH39", TXT_SHORE);
const TemplateTypeClass TemplateShore40(TEMPLATE_SHORE40, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH40", TXT_SHORE);
const TemplateTypeClass TemplateShore41(TEMPLATE_SHORE41, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH41", TXT_SHORE);
const TemplateTypeClass TemplateShore42(TEMPLATE_SHORE42, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH42", TXT_SHORE);
const TemplateTypeClass TemplateShore43(TEMPLATE_SHORE43, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH43", TXT_SHORE);
const TemplateTypeClass TemplateShore44(TEMPLATE_SHORE44, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH44", TXT_SHORE);
const TemplateTypeClass TemplateShore45(TEMPLATE_SHORE45, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH45", TXT_SHORE);
const TemplateTypeClass TemplateShore46(TEMPLATE_SHORE46, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH46", TXT_SHORE);
const TemplateTypeClass TemplateShore47(TEMPLATE_SHORE47, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH47", TXT_SHORE);
const TemplateTypeClass TemplateShore48(TEMPLATE_SHORE48, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH48", TXT_SHORE);
const TemplateTypeClass TemplateShore49(TEMPLATE_SHORE49, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH49", TXT_SHORE);
const TemplateTypeClass TemplateShore50(TEMPLATE_SHORE50, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH50", TXT_SHORE);
const TemplateTypeClass TemplateShore51(TEMPLATE_SHORE51, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH51", TXT_SHORE);
const TemplateTypeClass TemplateShore52(TEMPLATE_SHORE52, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH52", TXT_SHORE);
const TemplateTypeClass TemplateShore53(TEMPLATE_SHORE53, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH53", TXT_SHORE);
const TemplateTypeClass TemplateShore54(TEMPLATE_SHORE54, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH54", TXT_SHORE);
const TemplateTypeClass TemplateShore55(TEMPLATE_SHORE55, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH55", TXT_SHORE);
const TemplateTypeClass TemplateShore56(TEMPLATE_SHORE56, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "SH56", TXT_SHORE);

const TemplateTypeClass TemplateBoulder1(TEMPLATE_BOULDER1, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "B1", TXT_SLOPE);
const TemplateTypeClass TemplateBoulder2(TEMPLATE_BOULDER2, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "B2", TXT_SLOPE);
const TemplateTypeClass TemplateBoulder3(TEMPLATE_BOULDER3, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "B3", TXT_SLOPE);
const TemplateTypeClass TemplateBoulder4(TEMPLATE_BOULDER4, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "B4", TXT_SLOPE);
const TemplateTypeClass TemplateBoulder5(TEMPLATE_BOULDER5, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "B5", TXT_SLOPE);
const TemplateTypeClass TemplateBoulder6(TEMPLATE_BOULDER6, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "B6", TXT_SLOPE);

const TemplateTypeClass TemplateSlope01(TEMPLATE_SLOPE01, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S01", TXT_SLOPE);
const TemplateTypeClass TemplateSlope02(TEMPLATE_SLOPE02, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S02", TXT_SLOPE);
const TemplateTypeClass TemplateSlope03(TEMPLATE_SLOPE03, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S03", TXT_SLOPE);
const TemplateTypeClass TemplateSlope04(TEMPLATE_SLOPE04, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S04", TXT_SLOPE);
const TemplateTypeClass TemplateSlope05(TEMPLATE_SLOPE05, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S05", TXT_SLOPE);
const TemplateTypeClass TemplateSlope06(TEMPLATE_SLOPE06, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S06", TXT_SLOPE);
const TemplateTypeClass TemplateSlope07(TEMPLATE_SLOPE07, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S07", TXT_SLOPE);
const TemplateTypeClass TemplateSlope08(TEMPLATE_SLOPE08, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S08", TXT_SLOPE);
const TemplateTypeClass TemplateSlope09(TEMPLATE_SLOPE09, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S09", TXT_SLOPE);
const TemplateTypeClass TemplateSlope10(TEMPLATE_SLOPE10, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S10", TXT_SLOPE);
const TemplateTypeClass TemplateSlope11(TEMPLATE_SLOPE11, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S11", TXT_SLOPE);
const TemplateTypeClass TemplateSlope12(TEMPLATE_SLOPE12, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S12", TXT_SLOPE);
const TemplateTypeClass TemplateSlope13(TEMPLATE_SLOPE13, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S13", TXT_SLOPE);
const TemplateTypeClass TemplateSlope14(TEMPLATE_SLOPE14, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S14", TXT_SLOPE);
const TemplateTypeClass TemplateSlope15(TEMPLATE_SLOPE15, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S15", TXT_SLOPE);
const TemplateTypeClass TemplateSlope16(TEMPLATE_SLOPE16, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S16", TXT_SLOPE);
const TemplateTypeClass TemplateSlope17(TEMPLATE_SLOPE17, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S17", TXT_SLOPE);
const TemplateTypeClass TemplateSlope18(TEMPLATE_SLOPE18, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S18", TXT_SLOPE);
const TemplateTypeClass TemplateSlope19(TEMPLATE_SLOPE19, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S19", TXT_SLOPE);
const TemplateTypeClass TemplateSlope20(TEMPLATE_SLOPE20, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S20", TXT_SLOPE);
const TemplateTypeClass TemplateSlope21(TEMPLATE_SLOPE21, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S21", TXT_SLOPE);
const TemplateTypeClass TemplateSlope22(TEMPLATE_SLOPE22, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S22", TXT_SLOPE);
const TemplateTypeClass TemplateSlope23(TEMPLATE_SLOPE23, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S23", TXT_SLOPE);
const TemplateTypeClass TemplateSlope24(TEMPLATE_SLOPE24, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S24", TXT_SLOPE);
const TemplateTypeClass TemplateSlope25(TEMPLATE_SLOPE25, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S25", TXT_SLOPE);
const TemplateTypeClass TemplateSlope26(TEMPLATE_SLOPE26, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S26", TXT_SLOPE);
const TemplateTypeClass TemplateSlope27(TEMPLATE_SLOPE27, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S27", TXT_SLOPE);
const TemplateTypeClass TemplateSlope28(TEMPLATE_SLOPE28, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S28", TXT_SLOPE);
const TemplateTypeClass TemplateSlope29(TEMPLATE_SLOPE29, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S29", TXT_SLOPE);
const TemplateTypeClass TemplateSlope30(TEMPLATE_SLOPE30, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S30", TXT_SLOPE);
const TemplateTypeClass TemplateSlope31(TEMPLATE_SLOPE31, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S31", TXT_SLOPE);
const TemplateTypeClass TemplateSlope32(TEMPLATE_SLOPE32, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S32", TXT_SLOPE);
const TemplateTypeClass TemplateSlope33(TEMPLATE_SLOPE33, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S33", TXT_SLOPE);
const TemplateTypeClass TemplateSlope34(TEMPLATE_SLOPE34, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S34", TXT_SLOPE);
const TemplateTypeClass TemplateSlope35(TEMPLATE_SLOPE35, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S35", TXT_SLOPE);
const TemplateTypeClass TemplateSlope36(TEMPLATE_SLOPE36, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S36", TXT_SLOPE);
const TemplateTypeClass TemplateSlope37(TEMPLATE_SLOPE37, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S37", TXT_SLOPE);
const TemplateTypeClass TemplateSlope38(TEMPLATE_SLOPE38, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "S38", TXT_SLOPE);

const TemplateTypeClass TemplatePatch01(TEMPLATE_PATCH01, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "P01", TXT_PATCH);
const TemplateTypeClass TemplatePatch02(TEMPLATE_PATCH02, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "P02", TXT_PATCH);
const TemplateTypeClass TemplatePatch03(TEMPLATE_PATCH03, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "P03", TXT_PATCH);
const TemplateTypeClass TemplatePatch04(TEMPLATE_PATCH04, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "P04", TXT_PATCH);
const TemplateTypeClass TemplatePatch07(TEMPLATE_PATCH07, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "P07", TXT_PATCH);
const TemplateTypeClass TemplatePatch08(TEMPLATE_PATCH08, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "P08", TXT_PATCH);
const TemplateTypeClass TemplatePatch13(TEMPLATE_PATCH13, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "P13", TXT_PATCH);
const TemplateTypeClass TemplatePatch14(TEMPLATE_PATCH14, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "P14", TXT_PATCH);
const TemplateTypeClass TemplatePatch15(TEMPLATE_PATCH15, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "P15", TXT_PATCH);

const TemplateTypeClass TemplateRiver01(TEMPLATE_RIVER01, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RV01", TXT_RIVER);
const TemplateTypeClass TemplateRiver02(TEMPLATE_RIVER02, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RV02", TXT_RIVER);
const TemplateTypeClass TemplateRiver03(TEMPLATE_RIVER03, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RV03", TXT_RIVER);
const TemplateTypeClass TemplateRiver04(TEMPLATE_RIVER04, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RV04", TXT_RIVER);
const TemplateTypeClass TemplateRiver05(TEMPLATE_RIVER05, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RV05", TXT_RIVER);
const TemplateTypeClass TemplateRiver06(TEMPLATE_RIVER06, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RV06", TXT_RIVER);
const TemplateTypeClass TemplateRiver07(TEMPLATE_RIVER07, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RV07", TXT_RIVER);
const TemplateTypeClass TemplateRiver08(TEMPLATE_RIVER08, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RV08", TXT_RIVER);
const TemplateTypeClass TemplateRiver09(TEMPLATE_RIVER09, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RV09", TXT_RIVER);
const TemplateTypeClass TemplateRiver10(TEMPLATE_RIVER10, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RV10", TXT_RIVER);
const TemplateTypeClass TemplateRiver11(TEMPLATE_RIVER11, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RV11", TXT_RIVER);
const TemplateTypeClass TemplateRiver12(TEMPLATE_RIVER12, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RV12", TXT_RIVER);
const TemplateTypeClass TemplateRiver13(TEMPLATE_RIVER13, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RV13", TXT_RIVER);
const TemplateTypeClass TemplateRiver14(TEMPLATE_RIVER14, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RV14", TXT_RIVER);
const TemplateTypeClass TemplateRiver15(TEMPLATE_RIVER15, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RV15", TXT_RIVER);

const TemplateTypeClass TemplateFord1(TEMPLATE_FORD1, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "FORD1", TXT_RIVER);
const TemplateTypeClass TemplateFord2(TEMPLATE_FORD2, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "FORD2", TXT_RIVER);

const TemplateTypeClass TemplateFalls1(TEMPLATE_FALLS1, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "FALLS1", TXT_RIVER);
const TemplateTypeClass TemplateFalls1a(TEMPLATE_FALLS1A, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "FALLS1A", TXT_RIVER);
const TemplateTypeClass TemplateFalls2(TEMPLATE_FALLS2, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "FALLS2", TXT_RIVER);
const TemplateTypeClass TemplateFalls2a(TEMPLATE_FALLS2A, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "FALLS2A", TXT_RIVER);

const TemplateTypeClass TemplateBridge1x(TEMPLATE_BRIDGE1X, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BRIDGE1X", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge1(TEMPLATE_BRIDGE1, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BRIDGE1", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge1h(TEMPLATE_BRIDGE1H, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BRIDGE1H", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge1d(TEMPLATE_BRIDGE1D, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BRIDGE1D", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge2x(TEMPLATE_BRIDGE2X, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BRIDGE2X", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge2(TEMPLATE_BRIDGE2, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BRIDGE2", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge2h(TEMPLATE_BRIDGE2H, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BRIDGE2H", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge2d(TEMPLATE_BRIDGE2D, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BRIDGE2D", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge1ax(TEMPLATE_BRIDGE1AX, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BR1X", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge1a(TEMPLATE_BRIDGE1A, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BR1A", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge1b(TEMPLATE_BRIDGE1B, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BR1B", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge1c(TEMPLATE_BRIDGE1C, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BR1C", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge2ax(TEMPLATE_BRIDGE2AX, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BR2X", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge2a(TEMPLATE_BRIDGE2A, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BR2A", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge2b(TEMPLATE_BRIDGE2B, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BR2B", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge2c(TEMPLATE_BRIDGE2C, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BR2C", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge3a(TEMPLATE_BRIDGE3A, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BR3A", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge3b(TEMPLATE_BRIDGE3B, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BR3B", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge3c(TEMPLATE_BRIDGE3C, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BR3C", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge3d(TEMPLATE_BRIDGE3D, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BR3D", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge3e(TEMPLATE_BRIDGE3E, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BR3E", TXT_BRIDGE);
const TemplateTypeClass TemplateBridge3f(TEMPLATE_BRIDGE3F, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "BR3F", TXT_BRIDGE);

const TemplateTypeClass TemplateShoreCliff01(TEMPLATE_SHORECLIFF01, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC01", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff02(TEMPLATE_SHORECLIFF02, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC02", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff03(TEMPLATE_SHORECLIFF03, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC03", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff04(TEMPLATE_SHORECLIFF04, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC04", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff05(TEMPLATE_SHORECLIFF05, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC05", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff06(TEMPLATE_SHORECLIFF06, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC06", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff07(TEMPLATE_SHORECLIFF07, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC07", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff08(TEMPLATE_SHORECLIFF08, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC08", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff09(TEMPLATE_SHORECLIFF09, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC09", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff10(TEMPLATE_SHORECLIFF10, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC10", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff11(TEMPLATE_SHORECLIFF11, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC11", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff12(TEMPLATE_SHORECLIFF12, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC12", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff13(TEMPLATE_SHORECLIFF13, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC13", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff14(TEMPLATE_SHORECLIFF14, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC14", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff15(TEMPLATE_SHORECLIFF15, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC15", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff16(TEMPLATE_SHORECLIFF16, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC16", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff17(TEMPLATE_SHORECLIFF17, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC17", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff18(TEMPLATE_SHORECLIFF18, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC18", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff19(TEMPLATE_SHORECLIFF19, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC19", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff20(TEMPLATE_SHORECLIFF20, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC20", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff21(TEMPLATE_SHORECLIFF21, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC21", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff22(TEMPLATE_SHORECLIFF22, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC22", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff23(TEMPLATE_SHORECLIFF23, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC23", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff24(TEMPLATE_SHORECLIFF24, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC24", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff25(TEMPLATE_SHORECLIFF25, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC25", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff26(TEMPLATE_SHORECLIFF26, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC26", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff27(TEMPLATE_SHORECLIFF27, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC27", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff28(TEMPLATE_SHORECLIFF28, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC28", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff29(TEMPLATE_SHORECLIFF29, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC29", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff30(TEMPLATE_SHORECLIFF30, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC30", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff31(TEMPLATE_SHORECLIFF31, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC31", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff32(TEMPLATE_SHORECLIFF32, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC32", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff33(TEMPLATE_SHORECLIFF33, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC33", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff34(TEMPLATE_SHORECLIFF34, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC34", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff35(TEMPLATE_SHORECLIFF35, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC35", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff36(TEMPLATE_SHORECLIFF36, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC36", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff37(TEMPLATE_SHORECLIFF37, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC37", TXT_SHORE);
const TemplateTypeClass TemplateShoreCliff38(TEMPLATE_SHORECLIFF38, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "WC38", TXT_SHORE);

const TemplateTypeClass TemplateRough01(TEMPLATE_ROUGH01, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RF01", TXT_ROCK);
const TemplateTypeClass TemplateRough02(TEMPLATE_ROUGH02, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RF02", TXT_ROCK);
const TemplateTypeClass TemplateRough03(TEMPLATE_ROUGH03, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RF03", TXT_ROCK);
const TemplateTypeClass TemplateRough04(TEMPLATE_ROUGH04, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RF04", TXT_ROCK);
const TemplateTypeClass TemplateRough05(TEMPLATE_ROUGH05, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RF05", TXT_ROCK);
const TemplateTypeClass TemplateRough06(TEMPLATE_ROUGH06, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RF06", TXT_ROCK);
const TemplateTypeClass TemplateRough07(TEMPLATE_ROUGH07, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RF07", TXT_ROCK);
const TemplateTypeClass TemplateRough08(TEMPLATE_ROUGH08, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RF08", TXT_ROCK);
const TemplateTypeClass TemplateRough09(TEMPLATE_ROUGH09, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RF09", TXT_ROCK);
const TemplateTypeClass TemplateRough10(TEMPLATE_ROUGH10, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RF10", TXT_ROCK);
const TemplateTypeClass TemplateRough11(TEMPLATE_ROUGH11, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RF11", TXT_ROCK);

const TemplateTypeClass TemplateRiverCliff01(TEMPLATE_RIVERCLIFF01, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RC01", TXT_RIVER);
const TemplateTypeClass TemplateRiverCliff02(TEMPLATE_RIVERCLIFF02, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RC02", TXT_RIVER);
const TemplateTypeClass TemplateRiverCliff03(TEMPLATE_RIVERCLIFF03, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RC03", TXT_RIVER);
const TemplateTypeClass TemplateRiverCliff04(TEMPLATE_RIVERCLIFF04, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "RC04", TXT_RIVER);

const TemplateTypeClass TemplateF01(TEMPLATE_F01, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "F01", TXT_RIVER);
const TemplateTypeClass TemplateF02(TEMPLATE_F02, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "F02", TXT_RIVER);
const TemplateTypeClass TemplateF03(TEMPLATE_F03, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "F03", TXT_RIVER);
const TemplateTypeClass TemplateF04(TEMPLATE_F04, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "F04", TXT_RIVER);
const TemplateTypeClass TemplateF05(TEMPLATE_F05, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "F05", TXT_RIVER);
const TemplateTypeClass TemplateF06(TEMPLATE_F06, (TEM_THR_TEMPERAT | TEM_THR_SNOW), "F06", TXT_RIVER);

const TemplateTypeClass TemplateARRO0001(TEMPLATE_ARRO0001, TEM_THR_INTERIOR, "ARRO0001", TXT_INTERIOR);
const TemplateTypeClass TemplateARRO0002(TEMPLATE_ARRO0002, TEM_THR_INTERIOR, "ARRO0002", TXT_INTERIOR);
const TemplateTypeClass TemplateARRO0003(TEMPLATE_ARRO0003, TEM_THR_INTERIOR, "ARRO0003", TXT_INTERIOR);
const TemplateTypeClass TemplateARRO0004(TEMPLATE_ARRO0004, TEM_THR_INTERIOR, "ARRO0004", TXT_INTERIOR);
const TemplateTypeClass TemplateARRO0005(TEMPLATE_ARRO0005, TEM_THR_INTERIOR, "ARRO0005", TXT_INTERIOR);
const TemplateTypeClass TemplateARRO0006(TEMPLATE_ARRO0006, TEM_THR_INTERIOR, "ARRO0006", TXT_INTERIOR);
const TemplateTypeClass TemplateARRO0007(TEMPLATE_ARRO0007, TEM_THR_INTERIOR, "ARRO0007", TXT_INTERIOR);
const TemplateTypeClass TemplateARRO0008(TEMPLATE_ARRO0008, TEM_THR_INTERIOR, "ARRO0008", TXT_INTERIOR);
const TemplateTypeClass TemplateARRO0009(TEMPLATE_ARRO0009, TEM_THR_INTERIOR, "ARRO0009", TXT_INTERIOR);
const TemplateTypeClass TemplateARRO0010(TEMPLATE_ARRO0010, TEM_THR_INTERIOR, "ARRO0010", TXT_INTERIOR);
const TemplateTypeClass TemplateARRO0011(TEMPLATE_ARRO0011, TEM_THR_INTERIOR, "ARRO0011", TXT_INTERIOR);
const TemplateTypeClass TemplateARRO0012(TEMPLATE_ARRO0012, TEM_THR_INTERIOR, "ARRO0012", TXT_INTERIOR);
const TemplateTypeClass TemplateARRO0013(TEMPLATE_ARRO0013, TEM_THR_INTERIOR, "ARRO0013", TXT_INTERIOR);
const TemplateTypeClass TemplateARRO0014(TEMPLATE_ARRO0014, TEM_THR_INTERIOR, "ARRO0014", TXT_INTERIOR);
const TemplateTypeClass TemplateARRO0015(TEMPLATE_ARRO0015, TEM_THR_INTERIOR, "ARRO0015", TXT_INTERIOR);

const TemplateTypeClass TemplateFLOR0001(TEMPLATE_FLOR0001, TEM_THR_INTERIOR, "FLOR0001", TXT_INTERIOR);
const TemplateTypeClass TemplateFLOR0002(TEMPLATE_FLOR0002, TEM_THR_INTERIOR, "FLOR0002", TXT_INTERIOR);
const TemplateTypeClass TemplateFLOR0003(TEMPLATE_FLOR0003, TEM_THR_INTERIOR, "FLOR0003", TXT_INTERIOR);
const TemplateTypeClass TemplateFLOR0004(TEMPLATE_FLOR0004, TEM_THR_INTERIOR, "FLOR0004", TXT_INTERIOR);
const TemplateTypeClass TemplateFLOR0005(TEMPLATE_FLOR0005, TEM_THR_INTERIOR, "FLOR0005", TXT_INTERIOR);
const TemplateTypeClass TemplateFLOR0006(TEMPLATE_FLOR0006, TEM_THR_INTERIOR, "FLOR0006", TXT_INTERIOR);
const TemplateTypeClass TemplateFLOR0007(TEMPLATE_FLOR0007, TEM_THR_INTERIOR, "FLOR0007", TXT_INTERIOR);

const TemplateTypeClass TemplateGFLR0001(TEMPLATE_GFLR0001, TEM_THR_INTERIOR, "GFLR0001", TXT_INTERIOR);
const TemplateTypeClass TemplateGFLR0002(TEMPLATE_GFLR0002, TEM_THR_INTERIOR, "GFLR0002", TXT_INTERIOR);
const TemplateTypeClass TemplateGFLR0003(TEMPLATE_GFLR0003, TEM_THR_INTERIOR, "GFLR0003", TXT_INTERIOR);
const TemplateTypeClass TemplateGFLR0004(TEMPLATE_GFLR0004, TEM_THR_INTERIOR, "GFLR0004", TXT_INTERIOR);
const TemplateTypeClass TemplateGFLR0005(TEMPLATE_GFLR0005, TEM_THR_INTERIOR, "GFLR0005", TXT_INTERIOR);
const TemplateTypeClass TemplateGSTR0001(TEMPLATE_GSTR0001, TEM_THR_INTERIOR, "GSTR0001", TXT_INTERIOR);
const TemplateTypeClass TemplateGSTR0002(TEMPLATE_GSTR0002, TEM_THR_INTERIOR, "GSTR0002", TXT_INTERIOR);
const TemplateTypeClass TemplateGSTR0003(TEMPLATE_GSTR0003, TEM_THR_INTERIOR, "GSTR0003", TXT_INTERIOR);
const TemplateTypeClass TemplateGSTR0004(TEMPLATE_GSTR0004, TEM_THR_INTERIOR, "GSTR0004", TXT_INTERIOR);
const TemplateTypeClass TemplateGSTR0005(TEMPLATE_GSTR0005, TEM_THR_INTERIOR, "GSTR0005", TXT_INTERIOR);
const TemplateTypeClass TemplateGSTR0006(TEMPLATE_GSTR0006, TEM_THR_INTERIOR, "GSTR0006", TXT_INTERIOR);
const TemplateTypeClass TemplateGSTR0007(TEMPLATE_GSTR0007, TEM_THR_INTERIOR, "GSTR0007", TXT_INTERIOR);
const TemplateTypeClass TemplateGSTR0008(TEMPLATE_GSTR0008, TEM_THR_INTERIOR, "GSTR0008", TXT_INTERIOR);
const TemplateTypeClass TemplateGSTR0009(TEMPLATE_GSTR0009, TEM_THR_INTERIOR, "GSTR0009", TXT_INTERIOR);
const TemplateTypeClass TemplateGSTR0010(TEMPLATE_GSTR0010, TEM_THR_INTERIOR, "GSTR0010", TXT_INTERIOR);
const TemplateTypeClass TemplateGSTR0011(TEMPLATE_GSTR0011, TEM_THR_INTERIOR, "GSTR0011", TXT_INTERIOR);

const TemplateTypeClass TemplateLWAL0001(TEMPLATE_LWAL0001, TEM_THR_INTERIOR, "LWAL0001", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0002(TEMPLATE_LWAL0002, TEM_THR_INTERIOR, "LWAL0002", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0003(TEMPLATE_LWAL0003, TEM_THR_INTERIOR, "LWAL0003", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0004(TEMPLATE_LWAL0004, TEM_THR_INTERIOR, "LWAL0004", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0005(TEMPLATE_LWAL0005, TEM_THR_INTERIOR, "LWAL0005", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0006(TEMPLATE_LWAL0006, TEM_THR_INTERIOR, "LWAL0006", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0007(TEMPLATE_LWAL0007, TEM_THR_INTERIOR, "LWAL0007", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0008(TEMPLATE_LWAL0008, TEM_THR_INTERIOR, "LWAL0008", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0009(TEMPLATE_LWAL0009, TEM_THR_INTERIOR, "LWAL0009", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0010(TEMPLATE_LWAL0010, TEM_THR_INTERIOR, "LWAL0010", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0011(TEMPLATE_LWAL0011, TEM_THR_INTERIOR, "LWAL0011", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0012(TEMPLATE_LWAL0012, TEM_THR_INTERIOR, "LWAL0012", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0013(TEMPLATE_LWAL0013, TEM_THR_INTERIOR, "LWAL0013", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0014(TEMPLATE_LWAL0014, TEM_THR_INTERIOR, "LWAL0014", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0015(TEMPLATE_LWAL0015, TEM_THR_INTERIOR, "LWAL0015", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0016(TEMPLATE_LWAL0016, TEM_THR_INTERIOR, "LWAL0016", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0017(TEMPLATE_LWAL0017, TEM_THR_INTERIOR, "LWAL0017", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0018(TEMPLATE_LWAL0018, TEM_THR_INTERIOR, "LWAL0018", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0019(TEMPLATE_LWAL0019, TEM_THR_INTERIOR, "LWAL0019", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0020(TEMPLATE_LWAL0020, TEM_THR_INTERIOR, "LWAL0020", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0021(TEMPLATE_LWAL0021, TEM_THR_INTERIOR, "LWAL0021", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0022(TEMPLATE_LWAL0022, TEM_THR_INTERIOR, "LWAL0022", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0023(TEMPLATE_LWAL0023, TEM_THR_INTERIOR, "LWAL0023", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0024(TEMPLATE_LWAL0024, TEM_THR_INTERIOR, "LWAL0024", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0025(TEMPLATE_LWAL0025, TEM_THR_INTERIOR, "LWAL0025", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0026(TEMPLATE_LWAL0026, TEM_THR_INTERIOR, "LWAL0026", TXT_INTERIOR);
const TemplateTypeClass TemplateLWAL0027(TEMPLATE_LWAL0027, TEM_THR_INTERIOR, "LWAL0027", TXT_INTERIOR);

const TemplateTypeClass TemplateSTRP0001(TEMPLATE_STRP0001, TEM_THR_INTERIOR, "STRP0001", TXT_INTERIOR);
const TemplateTypeClass TemplateSTRP0002(TEMPLATE_STRP0002, TEM_THR_INTERIOR, "STRP0002", TXT_INTERIOR);
const TemplateTypeClass TemplateSTRP0003(TEMPLATE_STRP0003, TEM_THR_INTERIOR, "STRP0003", TXT_INTERIOR);
const TemplateTypeClass TemplateSTRP0004(TEMPLATE_STRP0004, TEM_THR_INTERIOR, "STRP0004", TXT_INTERIOR);
const TemplateTypeClass TemplateSTRP0005(TEMPLATE_STRP0005, TEM_THR_INTERIOR, "STRP0005", TXT_INTERIOR);
const TemplateTypeClass TemplateSTRP0006(TEMPLATE_STRP0006, TEM_THR_INTERIOR, "STRP0006", TXT_INTERIOR);
const TemplateTypeClass TemplateSTRP0007(TEMPLATE_STRP0007, TEM_THR_INTERIOR, "STRP0007", TXT_INTERIOR);
const TemplateTypeClass TemplateSTRP0008(TEMPLATE_STRP0008, TEM_THR_INTERIOR, "STRP0008", TXT_INTERIOR);
const TemplateTypeClass TemplateSTRP0009(TEMPLATE_STRP0009, TEM_THR_INTERIOR, "STRP0009", TXT_INTERIOR);
const TemplateTypeClass TemplateSTRP0010(TEMPLATE_STRP0010, TEM_THR_INTERIOR, "STRP0010", TXT_INTERIOR);
const TemplateTypeClass TemplateSTRP0011(TEMPLATE_STRP0011, TEM_THR_INTERIOR, "STRP0011", TXT_INTERIOR);

const TemplateTypeClass TemplateWALL0001(TEMPLATE_WALL0001, TEM_THR_INTERIOR, "WALL0001", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0002(TEMPLATE_WALL0002, TEM_THR_INTERIOR, "WALL0002", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0003(TEMPLATE_WALL0003, TEM_THR_INTERIOR, "WALL0003", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0004(TEMPLATE_WALL0004, TEM_THR_INTERIOR, "WALL0004", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0005(TEMPLATE_WALL0005, TEM_THR_INTERIOR, "WALL0005", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0006(TEMPLATE_WALL0006, TEM_THR_INTERIOR, "WALL0006", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0007(TEMPLATE_WALL0007, TEM_THR_INTERIOR, "WALL0007", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0008(TEMPLATE_WALL0008, TEM_THR_INTERIOR, "WALL0008", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0009(TEMPLATE_WALL0009, TEM_THR_INTERIOR, "WALL0009", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0010(TEMPLATE_WALL0010, TEM_THR_INTERIOR, "WALL0010", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0011(TEMPLATE_WALL0011, TEM_THR_INTERIOR, "WALL0011", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0012(TEMPLATE_WALL0012, TEM_THR_INTERIOR, "WALL0012", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0013(TEMPLATE_WALL0013, TEM_THR_INTERIOR, "WALL0013", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0014(TEMPLATE_WALL0014, TEM_THR_INTERIOR, "WALL0014", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0015(TEMPLATE_WALL0015, TEM_THR_INTERIOR, "WALL0015", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0016(TEMPLATE_WALL0016, TEM_THR_INTERIOR, "WALL0016", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0017(TEMPLATE_WALL0017, TEM_THR_INTERIOR, "WALL0017", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0018(TEMPLATE_WALL0018, TEM_THR_INTERIOR, "WALL0018", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0019(TEMPLATE_WALL0019, TEM_THR_INTERIOR, "WALL0019", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0020(TEMPLATE_WALL0020, TEM_THR_INTERIOR, "WALL0020", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0021(TEMPLATE_WALL0021, TEM_THR_INTERIOR, "WALL0021", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0022(TEMPLATE_WALL0022, TEM_THR_INTERIOR, "WALL0022", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0023(TEMPLATE_WALL0023, TEM_THR_INTERIOR, "WALL0023", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0024(TEMPLATE_WALL0024, TEM_THR_INTERIOR, "WALL0024", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0025(TEMPLATE_WALL0025, TEM_THR_INTERIOR, "WALL0025", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0026(TEMPLATE_WALL0026, TEM_THR_INTERIOR, "WALL0026", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0027(TEMPLATE_WALL0027, TEM_THR_INTERIOR, "WALL0027", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0028(TEMPLATE_WALL0028, TEM_THR_INTERIOR, "WALL0028", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0029(TEMPLATE_WALL0029, TEM_THR_INTERIOR, "WALL0029", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0030(TEMPLATE_WALL0030, TEM_THR_INTERIOR, "WALL0030", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0031(TEMPLATE_WALL0031, TEM_THR_INTERIOR, "WALL0031", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0032(TEMPLATE_WALL0032, TEM_THR_INTERIOR, "WALL0032", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0033(TEMPLATE_WALL0033, TEM_THR_INTERIOR, "WALL0033", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0034(TEMPLATE_WALL0034, TEM_THR_INTERIOR, "WALL0034", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0035(TEMPLATE_WALL0035, TEM_THR_INTERIOR, "WALL0035", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0036(TEMPLATE_WALL0036, TEM_THR_INTERIOR, "WALL0036", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0037(TEMPLATE_WALL0037, TEM_THR_INTERIOR, "WALL0037", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0038(TEMPLATE_WALL0038, TEM_THR_INTERIOR, "WALL0038", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0039(TEMPLATE_WALL0039, TEM_THR_INTERIOR, "WALL0039", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0040(TEMPLATE_WALL0040, TEM_THR_INTERIOR, "WALL0040", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0041(TEMPLATE_WALL0041, TEM_THR_INTERIOR, "WALL0041", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0042(TEMPLATE_WALL0042, TEM_THR_INTERIOR, "WALL0042", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0043(TEMPLATE_WALL0043, TEM_THR_INTERIOR, "WALL0043", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0044(TEMPLATE_WALL0044, TEM_THR_INTERIOR, "WALL0044", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0045(TEMPLATE_WALL0045, TEM_THR_INTERIOR, "WALL0045", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0046(TEMPLATE_WALL0046, TEM_THR_INTERIOR, "WALL0046", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0047(TEMPLATE_WALL0047, TEM_THR_INTERIOR, "WALL0047", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0048(TEMPLATE_WALL0048, TEM_THR_INTERIOR, "WALL0048", TXT_INTERIOR);
const TemplateTypeClass TemplateWALL0049(TEMPLATE_WALL0049, TEM_THR_INTERIOR, "WALL0049", TXT_INTERIOR);

const TemplateTypeClass TemplateXtra0001(TEMPLATE_XTRA0001, TEM_THR_INTERIOR, "XTRA0001", TXT_INTERIOR);
const TemplateTypeClass TemplateXtra0002(TEMPLATE_XTRA0002, TEM_THR_INTERIOR, "XTRA0002", TXT_INTERIOR);
const TemplateTypeClass TemplateXtra0003(TEMPLATE_XTRA0003, TEM_THR_INTERIOR, "XTRA0003", TXT_INTERIOR);
const TemplateTypeClass TemplateXtra0004(TEMPLATE_XTRA0004, TEM_THR_INTERIOR, "XTRA0004", TXT_INTERIOR);
const TemplateTypeClass TemplateXtra0005(TEMPLATE_XTRA0005, TEM_THR_INTERIOR, "XTRA0005", TXT_INTERIOR);
const TemplateTypeClass TemplateXtra0006(TEMPLATE_XTRA0006, TEM_THR_INTERIOR, "XTRA0006", TXT_INTERIOR);
const TemplateTypeClass TemplateXtra0007(TEMPLATE_XTRA0007, TEM_THR_INTERIOR, "XTRA0007", TXT_INTERIOR);
const TemplateTypeClass TemplateXtra0008(TEMPLATE_XTRA0008, TEM_THR_INTERIOR, "XTRA0008", TXT_INTERIOR);
const TemplateTypeClass TemplateXtra0009(TEMPLATE_XTRA0009, TEM_THR_INTERIOR, "XTRA0009", TXT_INTERIOR);
const TemplateTypeClass TemplateXtra0010(TEMPLATE_XTRA0010, TEM_THR_INTERIOR, "XTRA0010", TXT_INTERIOR);
const TemplateTypeClass TemplateXtra0011(TEMPLATE_XTRA0011, TEM_THR_INTERIOR, "XTRA0011", TXT_INTERIOR);
const TemplateTypeClass TemplateXtra0012(TEMPLATE_XTRA0012, TEM_THR_INTERIOR, "XTRA0012", TXT_INTERIOR);
const TemplateTypeClass TemplateXtra0013(TEMPLATE_XTRA0013, TEM_THR_INTERIOR, "XTRA0013", TXT_INTERIOR);
const TemplateTypeClass TemplateXtra0014(TEMPLATE_XTRA0014, TEM_THR_INTERIOR, "XTRA0014", TXT_INTERIOR);
const TemplateTypeClass TemplateXtra0015(TEMPLATE_XTRA0015, TEM_THR_INTERIOR, "XTRA0015", TXT_INTERIOR);
const TemplateTypeClass TemplateXtra0016(TEMPLATE_XTRA0016, TEM_THR_INTERIOR, "XTRA0016", TXT_INTERIOR);

const TemplateTypeClass TemplateAntHill(TEMPLATE_ANTHILL, TEM_THR_TEMPERAT, "HILL01", TXT_ROCK);

TemplateTypeClass::TemplateTypeClass(TemplateType type, int theater, const char *name, int uiname) :
    ObjectTypeClass(RTTI_TEMPLATETYPE,
    type,
    false,	//
    true,	//RadarInvisible
    false,	//Selectable
    false,	//LegalTarget
    true,	//Insignificant
    true,	//Immune
    false,	//
    uiname,
    name),
    Type(type),
    Theater(theater),
    Width(0),
    Height(0)
{
    
}

TemplateTypeClass::TemplateTypeClass(const TemplateTypeClass &that) :
    ObjectTypeClass(that),
    Type(that.Type),
    Theater(that.Theater),
    Width(that.Width),
    Height(that.Height)
{
    
}

void *TemplateTypeClass::operator new(size_t size)
{
    DEBUG_ASSERT(size == sizeof(TemplateTypeClass));
    return TemplateTypes.Allocate();
}

void TemplateTypeClass::operator delete(void *ptr)
{
    DEBUG_ASSERT(ptr != nullptr);
    TemplateTypes.Free(ptr);
}

void TemplateTypeClass::Init_Heap()
{
    // Order of creation must match order of TemplateType enum
    new TemplateTypeClass(TemplateClear);
    new TemplateTypeClass(TemplateWater);
    new TemplateTypeClass(TemplateWater2);

    new TemplateTypeClass(TemplateShore01);
    new TemplateTypeClass(TemplateShore02);
    new TemplateTypeClass(TemplateShore03);
    new TemplateTypeClass(TemplateShore04);
    new TemplateTypeClass(TemplateShore05);
    new TemplateTypeClass(TemplateShore06);
    new TemplateTypeClass(TemplateShore07);
    new TemplateTypeClass(TemplateShore08);
    new TemplateTypeClass(TemplateShore09);
    new TemplateTypeClass(TemplateShore10);
    new TemplateTypeClass(TemplateShore11);
    new TemplateTypeClass(TemplateShore12);
    new TemplateTypeClass(TemplateShore13);
    new TemplateTypeClass(TemplateShore14);
    new TemplateTypeClass(TemplateShore15);
    new TemplateTypeClass(TemplateShore16);
    new TemplateTypeClass(TemplateShore17);
    new TemplateTypeClass(TemplateShore18);
    new TemplateTypeClass(TemplateShore19);
    new TemplateTypeClass(TemplateShore20);
    new TemplateTypeClass(TemplateShore21);
    new TemplateTypeClass(TemplateShore22);
    new TemplateTypeClass(TemplateShore23);
    new TemplateTypeClass(TemplateShore24);
    new TemplateTypeClass(TemplateShore25);
    new TemplateTypeClass(TemplateShore26);
    new TemplateTypeClass(TemplateShore27);
    new TemplateTypeClass(TemplateShore28);
    new TemplateTypeClass(TemplateShore29);
    new TemplateTypeClass(TemplateShore30);
    new TemplateTypeClass(TemplateShore31);
    new TemplateTypeClass(TemplateShore32);
    new TemplateTypeClass(TemplateShore33);
    new TemplateTypeClass(TemplateShore34);
    new TemplateTypeClass(TemplateShore35);
    new TemplateTypeClass(TemplateShore36);
    new TemplateTypeClass(TemplateShore37);
    new TemplateTypeClass(TemplateShore38);
    new TemplateTypeClass(TemplateShore39);
    new TemplateTypeClass(TemplateShore40);
    new TemplateTypeClass(TemplateShore41);
    new TemplateTypeClass(TemplateShore42);
    new TemplateTypeClass(TemplateShore43);
    new TemplateTypeClass(TemplateShore44);
    new TemplateTypeClass(TemplateShore45);
    new TemplateTypeClass(TemplateShore46);
    new TemplateTypeClass(TemplateShore47);
    new TemplateTypeClass(TemplateShore48);
    new TemplateTypeClass(TemplateShore49);
    new TemplateTypeClass(TemplateShore50);
    new TemplateTypeClass(TemplateShore51);
    new TemplateTypeClass(TemplateShore52);
    new TemplateTypeClass(TemplateShore53);
    new TemplateTypeClass(TemplateShore54);
    new TemplateTypeClass(TemplateShore55);
    new TemplateTypeClass(TemplateShore56);

    new TemplateTypeClass(TemplateShoreCliff01);
    new TemplateTypeClass(TemplateShoreCliff02);
    new TemplateTypeClass(TemplateShoreCliff03);
    new TemplateTypeClass(TemplateShoreCliff04);
    new TemplateTypeClass(TemplateShoreCliff05);
    new TemplateTypeClass(TemplateShoreCliff06);
    new TemplateTypeClass(TemplateShoreCliff07);
    new TemplateTypeClass(TemplateShoreCliff08);
    new TemplateTypeClass(TemplateShoreCliff09);
    new TemplateTypeClass(TemplateShoreCliff10);
    new TemplateTypeClass(TemplateShoreCliff11);
    new TemplateTypeClass(TemplateShoreCliff12);
    new TemplateTypeClass(TemplateShoreCliff13);
    new TemplateTypeClass(TemplateShoreCliff14);
    new TemplateTypeClass(TemplateShoreCliff15);
    new TemplateTypeClass(TemplateShoreCliff16);
    new TemplateTypeClass(TemplateShoreCliff17);
    new TemplateTypeClass(TemplateShoreCliff18);
    new TemplateTypeClass(TemplateShoreCliff19);
    new TemplateTypeClass(TemplateShoreCliff20);
    new TemplateTypeClass(TemplateShoreCliff21);
    new TemplateTypeClass(TemplateShoreCliff22);
    new TemplateTypeClass(TemplateShoreCliff23);
    new TemplateTypeClass(TemplateShoreCliff24);
    new TemplateTypeClass(TemplateShoreCliff25);
    new TemplateTypeClass(TemplateShoreCliff26);
    new TemplateTypeClass(TemplateShoreCliff27);
    new TemplateTypeClass(TemplateShoreCliff28);
    new TemplateTypeClass(TemplateShoreCliff29);
    new TemplateTypeClass(TemplateShoreCliff30);
    new TemplateTypeClass(TemplateShoreCliff31);
    new TemplateTypeClass(TemplateShoreCliff32);
    new TemplateTypeClass(TemplateShoreCliff33);
    new TemplateTypeClass(TemplateShoreCliff34);
    new TemplateTypeClass(TemplateShoreCliff35);
    new TemplateTypeClass(TemplateShoreCliff36);
    new TemplateTypeClass(TemplateShoreCliff37);
    new TemplateTypeClass(TemplateShoreCliff38);

    new TemplateTypeClass(TemplateBoulder1);
    new TemplateTypeClass(TemplateBoulder2);
    new TemplateTypeClass(TemplateBoulder3);
    new TemplateTypeClass(TemplateBoulder4);
    new TemplateTypeClass(TemplateBoulder5);
    new TemplateTypeClass(TemplateBoulder6);

    new TemplateTypeClass(TemplatePatch01);
    new TemplateTypeClass(TemplatePatch02);
    new TemplateTypeClass(TemplatePatch03);
    new TemplateTypeClass(TemplatePatch04);
    new TemplateTypeClass(TemplatePatch07);
    new TemplateTypeClass(TemplatePatch08);
    new TemplateTypeClass(TemplatePatch13);
    new TemplateTypeClass(TemplatePatch14);
    new TemplateTypeClass(TemplatePatch15);

    new TemplateTypeClass(TemplateRiver01);
    new TemplateTypeClass(TemplateRiver02);
    new TemplateTypeClass(TemplateRiver03);
    new TemplateTypeClass(TemplateRiver04);
    new TemplateTypeClass(TemplateRiver05);
    new TemplateTypeClass(TemplateRiver06);
    new TemplateTypeClass(TemplateRiver07);
    new TemplateTypeClass(TemplateRiver08);
    new TemplateTypeClass(TemplateRiver09);
    new TemplateTypeClass(TemplateRiver10);
    new TemplateTypeClass(TemplateRiver11);
    new TemplateTypeClass(TemplateRiver12);
    new TemplateTypeClass(TemplateRiver13);

    new TemplateTypeClass(TemplateFalls1);
    new TemplateTypeClass(TemplateFalls1a);
    new TemplateTypeClass(TemplateFalls2);
    new TemplateTypeClass(TemplateFalls2a);

    new TemplateTypeClass(TemplateFord1);
    new TemplateTypeClass(TemplateFord2);

    new TemplateTypeClass(TemplateBridge1);
    new TemplateTypeClass(TemplateBridge1d);
    new TemplateTypeClass(TemplateBridge2);
    new TemplateTypeClass(TemplateBridge2d);

    new TemplateTypeClass(TemplateSlope01);
    new TemplateTypeClass(TemplateSlope02);
    new TemplateTypeClass(TemplateSlope03);
    new TemplateTypeClass(TemplateSlope04);
    new TemplateTypeClass(TemplateSlope05);
    new TemplateTypeClass(TemplateSlope06);
    new TemplateTypeClass(TemplateSlope07);
    new TemplateTypeClass(TemplateSlope08);
    new TemplateTypeClass(TemplateSlope09);
    new TemplateTypeClass(TemplateSlope10);
    new TemplateTypeClass(TemplateSlope11);
    new TemplateTypeClass(TemplateSlope12);
    new TemplateTypeClass(TemplateSlope13);
    new TemplateTypeClass(TemplateSlope14);
    new TemplateTypeClass(TemplateSlope15);
    new TemplateTypeClass(TemplateSlope16);
    new TemplateTypeClass(TemplateSlope17);
    new TemplateTypeClass(TemplateSlope18);
    new TemplateTypeClass(TemplateSlope19);
    new TemplateTypeClass(TemplateSlope20);
    new TemplateTypeClass(TemplateSlope21);
    new TemplateTypeClass(TemplateSlope22);
    new TemplateTypeClass(TemplateSlope23);
    new TemplateTypeClass(TemplateSlope24);
    new TemplateTypeClass(TemplateSlope25);
    new TemplateTypeClass(TemplateSlope26);
    new TemplateTypeClass(TemplateSlope27);
    new TemplateTypeClass(TemplateSlope28);
    new TemplateTypeClass(TemplateSlope29);
    new TemplateTypeClass(TemplateSlope30);
    new TemplateTypeClass(TemplateSlope31);
    new TemplateTypeClass(TemplateSlope32);
    new TemplateTypeClass(TemplateSlope33);
    new TemplateTypeClass(TemplateSlope34);
    new TemplateTypeClass(TemplateSlope35);
    new TemplateTypeClass(TemplateSlope36);
    new TemplateTypeClass(TemplateSlope37);
    new TemplateTypeClass(TemplateSlope38);

    new TemplateTypeClass(TemplateRoad01);
    new TemplateTypeClass(TemplateRoad02);
    new TemplateTypeClass(TemplateRoad03);
    new TemplateTypeClass(TemplateRoad04);
    new TemplateTypeClass(TemplateRoad05);
    new TemplateTypeClass(TemplateRoad06);
    new TemplateTypeClass(TemplateRoad07);
    new TemplateTypeClass(TemplateRoad08);
    new TemplateTypeClass(TemplateRoad09);
    new TemplateTypeClass(TemplateRoad10);
    new TemplateTypeClass(TemplateRoad11);
    new TemplateTypeClass(TemplateRoad12);
    new TemplateTypeClass(TemplateRoad13);
    new TemplateTypeClass(TemplateRoad14);
    new TemplateTypeClass(TemplateRoad15);
    new TemplateTypeClass(TemplateRoad16);
    new TemplateTypeClass(TemplateRoad17);
    new TemplateTypeClass(TemplateRoad18);
    new TemplateTypeClass(TemplateRoad19);
    new TemplateTypeClass(TemplateRoad20);
    new TemplateTypeClass(TemplateRoad21);
    new TemplateTypeClass(TemplateRoad22);
    new TemplateTypeClass(TemplateRoad23);
    new TemplateTypeClass(TemplateRoad24);
    new TemplateTypeClass(TemplateRoad25);
    new TemplateTypeClass(TemplateRoad26);
    new TemplateTypeClass(TemplateRoad27);
    new TemplateTypeClass(TemplateRoad28);
    new TemplateTypeClass(TemplateRoad29);
    new TemplateTypeClass(TemplateRoad30);
    new TemplateTypeClass(TemplateRoad31);
    new TemplateTypeClass(TemplateRoad32);
    new TemplateTypeClass(TemplateRoad33);
    new TemplateTypeClass(TemplateRoad34);
    new TemplateTypeClass(TemplateRoad35);
    new TemplateTypeClass(TemplateRoad36);
    new TemplateTypeClass(TemplateRoad37);
    new TemplateTypeClass(TemplateRoad38);
    new TemplateTypeClass(TemplateRoad39);
    new TemplateTypeClass(TemplateRoad40);
    new TemplateTypeClass(TemplateRoad41);
    new TemplateTypeClass(TemplateRoad42);
    new TemplateTypeClass(TemplateRoad43);

    new TemplateTypeClass(TemplateRough01);
    new TemplateTypeClass(TemplateRough02);
    new TemplateTypeClass(TemplateRough03);
    new TemplateTypeClass(TemplateRough04);
    new TemplateTypeClass(TemplateRough05);
    new TemplateTypeClass(TemplateRough06);
    new TemplateTypeClass(TemplateRough07);
    new TemplateTypeClass(TemplateRough08);
    new TemplateTypeClass(TemplateRough09);
    new TemplateTypeClass(TemplateRough10);
    new TemplateTypeClass(TemplateRough11);

    new TemplateTypeClass(TemplateRoad44);
    new TemplateTypeClass(TemplateRoad45);

    new TemplateTypeClass(TemplateRiver14);
    new TemplateTypeClass(TemplateRiver15);

    new TemplateTypeClass(TemplateRiverCliff01);
    new TemplateTypeClass(TemplateRiverCliff02);
    new TemplateTypeClass(TemplateRiverCliff03);
    new TemplateTypeClass(TemplateRiverCliff04);

    new TemplateTypeClass(TemplateBridge1a);
    new TemplateTypeClass(TemplateBridge1b);
    new TemplateTypeClass(TemplateBridge1c);

    new TemplateTypeClass(TemplateBridge2a);
    new TemplateTypeClass(TemplateBridge2b);
    new TemplateTypeClass(TemplateBridge2c);

    new TemplateTypeClass(TemplateBridge3a);
    new TemplateTypeClass(TemplateBridge3b);
    new TemplateTypeClass(TemplateBridge3c);
    new TemplateTypeClass(TemplateBridge3d);
    new TemplateTypeClass(TemplateBridge3e);
    new TemplateTypeClass(TemplateBridge3f);

    new TemplateTypeClass(TemplateF01);
    new TemplateTypeClass(TemplateF02);
    new TemplateTypeClass(TemplateF03);
    new TemplateTypeClass(TemplateF04);
    new TemplateTypeClass(TemplateF05);
    new TemplateTypeClass(TemplateF06);

    new TemplateTypeClass(TemplateARRO0001);
    new TemplateTypeClass(TemplateARRO0002);
    new TemplateTypeClass(TemplateARRO0003);
    new TemplateTypeClass(TemplateARRO0004);
    new TemplateTypeClass(TemplateARRO0005);
    new TemplateTypeClass(TemplateARRO0006);
    new TemplateTypeClass(TemplateARRO0007);
    new TemplateTypeClass(TemplateARRO0008);
    new TemplateTypeClass(TemplateARRO0009);
    new TemplateTypeClass(TemplateARRO0010);
    new TemplateTypeClass(TemplateARRO0011);
    new TemplateTypeClass(TemplateARRO0012);
    new TemplateTypeClass(TemplateARRO0013);
    new TemplateTypeClass(TemplateARRO0014);
    new TemplateTypeClass(TemplateARRO0015);

    new TemplateTypeClass(TemplateFLOR0001);
    new TemplateTypeClass(TemplateFLOR0002);
    new TemplateTypeClass(TemplateFLOR0003);
    new TemplateTypeClass(TemplateFLOR0004);
    new TemplateTypeClass(TemplateFLOR0005);
    new TemplateTypeClass(TemplateFLOR0006);
    new TemplateTypeClass(TemplateFLOR0007);

    new TemplateTypeClass(TemplateGFLR0001);
    new TemplateTypeClass(TemplateGFLR0002);
    new TemplateTypeClass(TemplateGFLR0003);
    new TemplateTypeClass(TemplateGFLR0004);
    new TemplateTypeClass(TemplateGFLR0005);
    new TemplateTypeClass(TemplateGSTR0001);
    new TemplateTypeClass(TemplateGSTR0002);
    new TemplateTypeClass(TemplateGSTR0003);
    new TemplateTypeClass(TemplateGSTR0004);
    new TemplateTypeClass(TemplateGSTR0005);
    new TemplateTypeClass(TemplateGSTR0006);
    new TemplateTypeClass(TemplateGSTR0007);
    new TemplateTypeClass(TemplateGSTR0008);
    new TemplateTypeClass(TemplateGSTR0009);
    new TemplateTypeClass(TemplateGSTR0010);
    new TemplateTypeClass(TemplateGSTR0011);

    new TemplateTypeClass(TemplateLWAL0001);
    new TemplateTypeClass(TemplateLWAL0002);
    new TemplateTypeClass(TemplateLWAL0003);
    new TemplateTypeClass(TemplateLWAL0004);
    new TemplateTypeClass(TemplateLWAL0005);
    new TemplateTypeClass(TemplateLWAL0006);
    new TemplateTypeClass(TemplateLWAL0007);
    new TemplateTypeClass(TemplateLWAL0008);
    new TemplateTypeClass(TemplateLWAL0009);
    new TemplateTypeClass(TemplateLWAL0010);
    new TemplateTypeClass(TemplateLWAL0011);
    new TemplateTypeClass(TemplateLWAL0012);
    new TemplateTypeClass(TemplateLWAL0013);
    new TemplateTypeClass(TemplateLWAL0014);
    new TemplateTypeClass(TemplateLWAL0015);
    new TemplateTypeClass(TemplateLWAL0016);
    new TemplateTypeClass(TemplateLWAL0017);
    new TemplateTypeClass(TemplateLWAL0018);
    new TemplateTypeClass(TemplateLWAL0019);
    new TemplateTypeClass(TemplateLWAL0020);
    new TemplateTypeClass(TemplateLWAL0021);
    new TemplateTypeClass(TemplateLWAL0022);
    new TemplateTypeClass(TemplateLWAL0023);
    new TemplateTypeClass(TemplateLWAL0024);
    new TemplateTypeClass(TemplateLWAL0025);
    new TemplateTypeClass(TemplateLWAL0026);
    new TemplateTypeClass(TemplateLWAL0027);

    new TemplateTypeClass(TemplateSTRP0001);
    new TemplateTypeClass(TemplateSTRP0002);
    new TemplateTypeClass(TemplateSTRP0003);
    new TemplateTypeClass(TemplateSTRP0004);
    new TemplateTypeClass(TemplateSTRP0005);
    new TemplateTypeClass(TemplateSTRP0006);
    new TemplateTypeClass(TemplateSTRP0007);
    new TemplateTypeClass(TemplateSTRP0008);
    new TemplateTypeClass(TemplateSTRP0009);
    new TemplateTypeClass(TemplateSTRP0010);
    new TemplateTypeClass(TemplateSTRP0011);

    new TemplateTypeClass(TemplateWALL0001);
    new TemplateTypeClass(TemplateWALL0002);
    new TemplateTypeClass(TemplateWALL0003);
    new TemplateTypeClass(TemplateWALL0004);
    new TemplateTypeClass(TemplateWALL0005);
    new TemplateTypeClass(TemplateWALL0006);
    new TemplateTypeClass(TemplateWALL0007);
    new TemplateTypeClass(TemplateWALL0008);
    new TemplateTypeClass(TemplateWALL0009);
    new TemplateTypeClass(TemplateWALL0010);
    new TemplateTypeClass(TemplateWALL0011);
    new TemplateTypeClass(TemplateWALL0012);
    new TemplateTypeClass(TemplateWALL0013);
    new TemplateTypeClass(TemplateWALL0014);
    new TemplateTypeClass(TemplateWALL0015);
    new TemplateTypeClass(TemplateWALL0016);
    new TemplateTypeClass(TemplateWALL0017);
    new TemplateTypeClass(TemplateWALL0018);
    new TemplateTypeClass(TemplateWALL0019);
    new TemplateTypeClass(TemplateWALL0020);
    new TemplateTypeClass(TemplateWALL0021);
    new TemplateTypeClass(TemplateWALL0022);
    new TemplateTypeClass(TemplateWALL0023);
    new TemplateTypeClass(TemplateWALL0024);
    new TemplateTypeClass(TemplateWALL0025);
    new TemplateTypeClass(TemplateWALL0026);
    new TemplateTypeClass(TemplateWALL0027);
    new TemplateTypeClass(TemplateWALL0028);
    new TemplateTypeClass(TemplateWALL0029);
    new TemplateTypeClass(TemplateWALL0030);
    new TemplateTypeClass(TemplateWALL0031);
    new TemplateTypeClass(TemplateWALL0032);
    new TemplateTypeClass(TemplateWALL0033);
    new TemplateTypeClass(TemplateWALL0034);
    new TemplateTypeClass(TemplateWALL0035);
    new TemplateTypeClass(TemplateWALL0036);
    new TemplateTypeClass(TemplateWALL0037);
    new TemplateTypeClass(TemplateWALL0038);
    new TemplateTypeClass(TemplateWALL0039);
    new TemplateTypeClass(TemplateWALL0040);
    new TemplateTypeClass(TemplateWALL0041);
    new TemplateTypeClass(TemplateWALL0042);
    new TemplateTypeClass(TemplateWALL0043);
    new TemplateTypeClass(TemplateWALL0044);
    new TemplateTypeClass(TemplateWALL0045);
    new TemplateTypeClass(TemplateWALL0046);
    new TemplateTypeClass(TemplateWALL0047);
    new TemplateTypeClass(TemplateWALL0048);
    new TemplateTypeClass(TemplateWALL0049);

    new TemplateTypeClass(TemplateBridge1h);
    new TemplateTypeClass(TemplateBridge2h);
    new TemplateTypeClass(TemplateBridge1ax);
    new TemplateTypeClass(TemplateBridge2ax);
    new TemplateTypeClass(TemplateBridge1x);
    new TemplateTypeClass(TemplateBridge2x);

    new TemplateTypeClass(TemplateXtra0001);
    new TemplateTypeClass(TemplateXtra0002);
    new TemplateTypeClass(TemplateXtra0003);
    new TemplateTypeClass(TemplateXtra0004);
    new TemplateTypeClass(TemplateXtra0005);
    new TemplateTypeClass(TemplateXtra0006);
    new TemplateTypeClass(TemplateXtra0007);
    new TemplateTypeClass(TemplateXtra0008);
    new TemplateTypeClass(TemplateXtra0009);
    new TemplateTypeClass(TemplateXtra0010);
    new TemplateTypeClass(TemplateXtra0011);
    new TemplateTypeClass(TemplateXtra0012);
    new TemplateTypeClass(TemplateXtra0013);
    new TemplateTypeClass(TemplateXtra0014);
    new TemplateTypeClass(TemplateXtra0015);
    new TemplateTypeClass(TemplateXtra0016);

    new TemplateTypeClass(TemplateAntHill);

}

void TemplateTypeClass::Init(TheaterType theater)
{
    // TODO Needs IconSet functions and TheaterTypeClass
#ifndef CHRONOSHIFT_STANDALONE
    void(*func)(TheaterType) = reinterpret_cast<void(*)(TheaterType)>(0x0049EAB0);
    func(theater);
#elif 0
    char buffer[256];

    for (TemplateType i = TEMPLATE_FIRST; i < TEMPLATE_COUNT; ++i) {
        TemplateTypeClass &tem = As_Reference(i);

        if (((1 << theater) & tem.Theater) != 0) {
            const char *name = tem.ImageName[0] != '\0' ? tem.ImageName : tem.Get_Name();

            sprintf(buffer, "%s.%s", name, TheaterTypeClass::As_Reference(theater).FileExt);
            tem.ImageData = GameFileClass::Retrieve(buffer);

            IconSetClass::Register_Icon_Set(tem.ImageData, true);

            tem.Width = 0;
            tem.Height = 0;

            if (tem.ImageData != nullptr) {
                tem.Width = Max(int16_t(0), IconSetClass::Get_Icon_Set_Width(static_cast<IconControlType *>(tem.ImageData)));
                tem.Height = Max(int16_t(0), IconSetClass::Get_Icon_Set_Height(static_cast<IconControlType *>(tem.ImageData)));

            }

        }

    }
#else

#endif
}

BOOL TemplateTypeClass::Create_And_Place(int16_t cellnum, HousesType house) const
{
    // TODO requires TemplateClass
#ifndef CHRONOSHIFT_STANDALONE
    BOOL(*func)(const TemplateTypeClass*, int16_t, HousesType) = reinterpret_cast<BOOL(*)(const TemplateTypeClass*, int16_t, HousesType)>(0x0049EB84);
    return func(this, cellnum, house);
#elif 0
    DEBUG_ASSERT(this != nullptr);

    TemplateClass *tptr = new TemplateClass(Type, cellnum);
    DEBUG_ASSERT(tptr != nullptr);

    return tptr != nullptr;
#else
    return false;
#endif
}

ObjectClass *TemplateTypeClass::Create_One_Of(HouseClass *house) const
{
    // TODO requires TemplateClass
#ifndef CHRONOSHIFT_STANDALONE
    ObjectClass *(*func)(const TemplateTypeClass*, HouseClass*) = reinterpret_cast<ObjectClass *(*)(const TemplateTypeClass*, HouseClass*)>(0x0049EBBC);
    return func(this, house);
#elif 0
    DEBUG_ASSERT(this != nullptr);
    //DEBUG_ASSERT(house != nullptr);

    TemplateClass *tptr = new TemplateClass(Type);
    DEBUG_ASSERT(tptr != nullptr);

    return tptr;
#else
    return nullptr;
#endif
}

LandType TemplateTypeClass::Land_Type(int sub_icon) const
{
    // TODO requires IconControlType
#ifndef CHRONOSHIFT_STANDALONE
    LandType(*func)(const TemplateTypeClass*, int) = reinterpret_cast<LandType(*)(const TemplateTypeClass*, int)>(0x0049E98C);
    return func(this, sub_icon);
#elif 0
    // I think it works like this, the enum entries are the index into _land
    // which matches the Template _LandType to th actual LandType type.
    enum TemplateLandType
    {
        TLAND_NONE = LAND_NONE,
        TLAND_FIRST = 0,
        TLAND_0 = 0,
        TLAND_1 = 1,		//used for the ant hill.
        TLAND_2 = 2,
        TLAND_3 = 3,		//used for roads, water, shores...
        TLAND_4 = 4,		//used for what i think are interior tiles.
        TLAND_5 = 5,
        TLAND_6 = 6,
        TLAND_7 = 7,		//used for clear.
        TLAND_8 = 8,
        TLAND_9 = 9,
        TLAND_10 = 10,
        TLAND_11 = 11,
        TLAND_12 = 12,
        TLAND_13 = 13,
        TLAND_14 = 14,
        TLAND_15 = 15,
        TLAND_COUNT = 16
    };

    static LandType _land[TLAND_COUNT] = {
        LAND_CLEAR, LAND_CLEAR, LAND_CLEAR, LAND_CLEAR,
        LAND_CLEAR, LAND_CLEAR, LAND_BEACH, LAND_CLEAR,
        LAND_ROCK,  LAND_ROAD,  LAND_WATER, LAND_RIVER,
        LAND_CLEAR, LAND_CLEAR, LAND_ROUGH, LAND_CLEAR
    };

    IconControlType *icon = (IconControlType *)ImageData;
    char *cmaps = nullptr;

    //accesses the raw image data of the template and get the _landtype.
    //Realistically, the assignment probably won't fail as its just a spot of
    //pointer arithmetic on a pointer we already checked wasn't NULL
    if (ImageData != nullptr && (cmaps = (char *)icon + icon->ColorMap) != nullptr) {
        return _land[cmaps[sub_icon % icon->MapWidth * icon->MapHeight]];
    }

    return LAND_NONE;
#else
    return LAND_NONE;
#endif
}

TemplateType TemplateTypeClass::From_Name(const char *name)
{
    DEBUG_ASSERT(name != nullptr);

    if (strcasecmp(name, "<none>") == 0 || strcasecmp(name, "none") == 0) {
        return TEMPLATE_NONE;
    }

    if (name != nullptr) {
        for (TemplateType tem = TEMPLATE_FIRST; tem < TEMPLATE_COUNT; ++tem) {

            if (strcasecmp(name, Name_From(tem)) == 0) {
                return tem;
            }

        }

    }

    return TEMPLATE_NONE;
}

const char *TemplateTypeClass::Name_From(TemplateType tem)
{
    DEBUG_ASSERT(tem != TEMPLATE_NONE);
    DEBUG_ASSERT(tem < TEMPLATE_COUNT);

    return tem != TEMPLATE_NONE && tem < TEMPLATE_COUNT ? As_Reference(tem).Get_Name() : "<none>";
}


const int16_t *TemplateTypeClass::Occupy_List(BOOL a1) const
{
    // TODO requires IconControlType
#ifndef CHRONOSHIFT_STANDALONE
    const int16_t *(*func)(const TemplateTypeClass*, BOOL) = reinterpret_cast<const int16_t *(*)(const TemplateTypeClass*, BOOL)>(0x0049EA2C);
    return func(this, a1);
#else
    return nullptr;
#endif
}

TemplateTypeClass *TemplateTypeClass::As_Pointer(TemplateType tem)
{
    if (tem != TEMPLATE_NONE && tem < TEMPLATE_COUNT) {
        TemplateTypeClass *ptr = &TemplateTypes[tem];
        DEBUG_ASSERT(ptr != nullptr);
        return ptr;
    }

    return nullptr;
}

TemplateTypeClass &TemplateTypeClass::As_Reference(TemplateType tem)
{
    DEBUG_ASSERT(tem != TEMPLATE_NONE);
    DEBUG_ASSERT(tem < TEMPLATE_COUNT);

    TemplateTypeClass *ttypeptr = &TemplateTypes[tem];
    DEBUG_ASSERT(ttypeptr != nullptr);

    return *ttypeptr;
}

uint32_t TemplateTypeClass::Coord_Fixup(uint32_t coord) const
{
    DEBUG_ASSERT(this != nullptr);

    return Coord_Top_Left(coord);
}

void TemplateTypeClass::MapEditor_418A1C()
{
#if 0 // TODO Requires MapEditor layer of IOMap stack
    for (TemplateType tem = TEMPLATE_FIRST; tem < TEMPLATE_COUNT; ++tem) {
        TemplateTypeClass *tptr = As_Pointer(tem);
        DEBUG_ASSERT(tptr != nullptr);
        if (tptr != nullptr) {
            if (tptr->Get_Image_Data() != nullptr) {
                Map.MapEditorClass_449A29(tptr);
            }
        }
    }
#else

#endif
}
